package dbPhase.hypeerweb;

import java.util.HashMap;

/*An arbitrary collection of named objects.

 Domain:
     parameters : Map -- a set of key-value pairs such that no two key-value pairs have the same key.*/
public class Parameters {
	HashMap<String, Object> parameters;

	public Parameters() {
		parameters = new HashMap<String, Object>();
	}

	/*Returns true or false depending on whether or not there exists a key-value pair with the given key.
Parameters:
key - the key we are searching for.
Pre-condition:
None
Post-condition:
result = ∃ k, object ((k, object) ∈ parameters AND k = key)
-- The object may be null.*/
	public boolean containsKey(String key) {
		return parameters.containsKey(key);
	}

	/*Retrieves an object from the parameters with the given key.
Pre-condition:
None
Post-condition:
∃ k, v ((k, v) ∈ parameters AND k = key) ⇒ result = v)
ELSE
     result = null*/
	public Object get(String key) {
		return parameters.get(key);
	}

	/*Inserts the key-value pair (key, value) into the parameters. If there was a key-value pair with the given key, it is removed
	 * from the parameters before inserting the new key-value pair. The value may be null.
Pre-condition:
key ≠ null
Post-condition:
(key, value) ∈ parameters*/
	public void set(String key, Object value) {
		parameters.put(key, value);
	}
}
